package com.hxzy.service.impl;

import com.hxzy.mapper.UserMapper;
import com.hxzy.pojo.User;
import com.hxzy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zl
 * @create 2020-10-29 14:30
 */
@Transactional
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean existsUsername(String username) {
        User user = userMapper.selectByUsername(username);
        return (user == null)? false : true;
    }

    @Override
    public User login(String username, String password) {
        return userMapper.selectByUsernameAndPassword(username, password);
    }

    @Override
    public int registerUser(User user) {
        return userMapper.saveUser(user);
    }
}
